package ast


type Type struct {
	Node        `part:"type"`
	Ref   Ref   `part:"ref"`
}
type Ref struct {
	Node                `part:"ref"`
	Base      RefBase   `part:"ref_base"`
	TypeArgs  [] Type   `list:"type_args.type*,"`
}
type RefBase struct {
	Node                      `part:"ref_base"`
	NS      MaybeIdentifier   `part_opt:"ns_prefix.name"`
	Item    Identifier        `part:"name"`
}
type MaybeIdentifier interface { impl(MaybeIdentifier) }
func (Identifier) impl(MaybeIdentifier) {}
type Identifier struct {
	Node         `part:"name"`
	Name  Code   `content:"Name"`
}

type VariousTypeDef struct {
	Node               `part:"type_def"`
	TypeDef  TypeDef   `use:"first"`
}
type TypeDef interface { impl(TypeDef) }

func (NativeTypeDef) impl(TypeDef) {}
type NativeTypeDef struct {
	Node `part:"native_type_def"`
}

func (Interface) impl(TypeDef) {}
type Interface struct {
	Node                 `part:"interface"`
	Methods  [] Method   `list:"method*,"`
}
type Method struct {
	Node               `part:"method"`
	Docs  [] Doc       `list:"docs.doc+"`
	Name  Identifier   `part:"name"`
	Type  Type         `part:"type"`
}

func (Record) impl(TypeDef) {}
type Record struct {
	Node              `part:"record"`
	Def   RecordDef   `part:"record_def"`
}
type RecordDef struct {
	Node               `part:"record_def"`
	Fields  [] Field   `list:"field*,"`
}
type Field struct {
	Node                  `part:"field"`
	Docs     [] Doc       `list:"docs.doc+"`
	Name     Identifier   `part:"name"`
	Type     Type         `part:"type"`
	Default  MaybeExpr    `part_opt:"field_default.expr"`
}

func (Union) impl(TypeDef) {}
type Union struct {
	Node             `part:"union"`
	Items  [] Type   `list:"type+,"`
}

func (Enum) impl(TypeDef) {}
type Enum struct {
	Node                 `part:"enum"`
	Items  [] EnumItem   `list:"enum_item+,"`
}
type EnumItem struct {
	Node               `part:"enum_item"`
	Docs  [] Doc       `list:"docs.doc+"`
	Name  Identifier   `part:"name"`
}


